import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;


public class FileUtil {

	static String s = ".png";
	static String splite="!^$^!";
	public static void make(int ... idx) throws IOException{
		File f = new File("idx"+s);
		if(f.exists()){
			f.delete();
		}
		f.createNewFile();
		FileOutputStream out = new FileOutputStream(f);

		boolean first = true;
		for (int id : idx) {
			String write="";
			if(first){
				first=false;
			}else{
				write+="\n";
			}
			write+=id+splite;
			File idFile = new File("f/"+id+s);
			BufferedReader br = new BufferedReader(new FileReader(idFile));
			String tmp;
			int seek=0;
			write+=seek+"";
			int lastSeek=0;
			while ((tmp=br.readLine())!=null) {
				System.out.println(tmp);
				seek+=tmp.length()+2;
				lastSeek = seek;
				write+=","+seek;
			}
			br.close();
			out.write(write.substring(0,write.length()-(1+(lastSeek+"").length())).getBytes());
		}
		out.close();
	}
}
